﻿package
{	
	import flash.display.Sprite;
	import flash.events.Event;
	
	import sk.prasa.webapis.picasa.PicasaService;
	import sk.prasa.webapis.picasa.events.PicasaEvent;	
	import sk.prasa.webapis.picasa.Album;
		
	public class TestAsyncLoadMain extends Sprite
	{		
		public function TestAsyncLoadMain()
		{						
			initPicasa();			
		}

		public function initPicasa()
		{
			var service: PicasaService = new PicasaService();			
			service.addEventListener(PicasaEvent.PHOTOS_GET_LIST, this.handleFotoList1 );						
			service.photos.list("sascha.seewald","5157613055208318321");
			/*
			service.addEventListener(PicasaEvent.PHOTOS_GET_LIST, this.handleFotoList2);			
			service.photos.list("sascha.seewald","5155031822813094897");
			service.addEventListener(PicasaEvent.PHOTOS_GET_LIST, this.handleFotoList3);			
			service.photos.list("sascha.seewald","5152872046968692897");			
			*/
		}		
		
		function handleFotoList1(evt:PicasaEvent)
		{
			if (evt.success)
			{
				trace("1: This album contains "+evt.data.length+" photos");
				
				//var a: AlbumData = new AlbumData( "", "" );	
				//a.getFotoList();
				
				trace( evt.target.toString() );				
			}
			else
			{
				trace(evt.error.message);
			}			
			
			//evt.target.removeEventListener(evt.type, this.handleFotoList1);			
		}
		
		function handleFotoList2(evt:PicasaEvent)
		{
			if (evt.success)
			{
				trace("2: This album contains "+evt.data.length+" photos");
			}
			else
			{
				trace(evt.error.message);
			}									
			
			//evt.target.removeEventListener(evt.type, this.handleFotoList2);			
		}
		
		function handleFotoList3(evt:PicasaEvent)
		{
			if (evt.success)
			{
				trace("3: This album contains "+evt.data.length+" photos");
			}
			else
			{
				trace(evt.error.message);
			}			
			
			//evt.target.removeEventListener(evt.type, this.handleFotoList3);			
		}		
	}
				
}